﻿using System.Collections.Generic;
using Missbot.Service;

namespace Missbot.MisskeyClient
{
    public class MisskeyClientMeta : DbBaseEntity
    {
        public string Name { get; set; }
        
        public string I { get; set; }
        
        public string[] EnableChannels { get; set; }
    }

    public static class MisskeyClientMetaDA
    {
        public static List<MisskeyClientMeta> GetAll()
        {
            return MongoService<MisskeyClientMeta>.Get();
        }

        public static void Insert(this MisskeyClientMeta meta)
        {
            MongoService<MisskeyClientMeta>.Insert(meta);
        }

        public static bool IsValid(this MisskeyClientMeta meta)
        {
            if (string.IsNullOrEmpty(meta.Name) || string.IsNullOrEmpty(meta.I))
            {
                return false;
            }

            return MongoService<MisskeyClientMeta>.Count(p => p.Name == meta.Name) == 0;
        }
    }
}